<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:rich="http://richfaces.org/rich">
    <style type="text/css">
        input[type='submit']{
            margin: 3px 5px 3px 5px;
            padding:3px 5px 3px 5px;
        }
        .treeRow{
            vertical-align:top;
        }
        .irow{
            padding:4px 3px 4px 3px;
            margin:2px 3px 2px 3px;
        }
        #cateAssetTable.tr{
            padding:4px 3px 4px 3px;
            margin:2px 3px 2px 3px;
        }
        #cateAssetTable td{
            padding:4px 3px 4px 3px;
            margin:2px 3px 2px 3px;
        }
    </style>
    <h:form>
        <rich:panel header="资产编辑" styleClass="content-hight">
            <h:panelGrid columns="4">
                <h:outputLabel value="部 门: " />
                <h:selectOneMenu  value="#{assetEditBean.deptCode}">
                    <f:selectItem itemValue="" itemLabel="-请选择-"/>
                    <f:selectItems value="#{assetEditBean.deptSelectli}"/>
                    <a4j:ajax event="change" listener="#{assetEditBean.deptChange}" render="userList"/>
                </h:selectOneMenu>
                <h:outputText value="购置日期："/>
                <h:panelGroup>
                    <rich:calendar value="#{assetEditBean.condition.purchDateB}"
                                   locale="zh_CN"
                                   popup="true"
                                   datePattern="yyyy-MM-dd"
                                   showApplyButton="false"  style="width:200px"/>
                    至
                    <rich:calendar value="#{assetEditBean.condition.purchDateE}"
                                   locale="zh_CN"
                                   popup="true"
                                   datePattern="yyyy-MM-dd"
                                   showApplyButton="false"  style="width:200px"/>
                </h:panelGroup>
                <h:outputLabel value="使用人: " />
                <h:panelGroup>
                    <h:selectOneMenu id="userList"  value="#{assetEditBean.condition.person.cpsn_name}">
                        <f:selectItem itemValue="" itemLabel="-请选择-"/>
                        <f:selectItems value="#{assetEditBean.personSelectli}" />
                    </h:selectOneMenu>
                </h:panelGroup>
                <h:outputText value="质保日期："/>
                <h:panelGroup>
                    <rich:calendar value="#{assetEditBean.condition.shelfLifeB}"
                                   locale="zh_CN"
                                   popup="true"
                                   datePattern="yyyy-MM-dd"
                                   showApplyButton="false"  style="width:200px"/>
                    至
                    <rich:calendar value="#{assetEditBean.condition.shelfLifeE}"
                                   locale="zh_CN"
                                   popup="true"
                                   datePattern="yyyy-MM-dd"
                                   showApplyButton="false"  style="width:200px"/>
                </h:panelGroup>
                <h:outputLabel value="资产名称:" />
                <h:selectOneMenu  value="#{assetEditBean.condition.assetName}" >
                    <f:selectItem itemValue="" itemLabel="-请选择-"/>
                    <f:selectItems value="#{assetQueryBean.seleli}"/>
                </h:selectOneMenu>
                <h:outputLabel value="单价：" />
                <h:panelGroup>
                    <h:inputText size="23"  value="#{assetEditBean.condition.priceB}"/>
                    -<h:inputText size="23"  value="#{assetEditBean.condition.priceE}"/>
                </h:panelGroup>
                <h:outputLabel value="是否来自政采：" />
                        <h:selectOneMenu value="#{assetEditBean.fromProcure}">
                            <f:selectItem itemValue="" itemLabel="-请选择-"/>
                            <f:selectItem itemValue="1" itemLabel="是"/>
                            <f:selectItem itemValue="0" itemLabel="否"/>
                            <a4j:ajax event="change" render="button"/>
                        </h:selectOneMenu>
            </h:panelGrid>
            <h:panelGroup id="editArea">
                <rich:toolbar  itemSeparator="Grid">
                    <rich:toolbarGroup>
                        <a4j:commandButton value="查询" action="#{assetEditBean.queryAsset}" render="sasetEditGroup"/>
                    </rich:toolbarGroup>
                    <rich:toolbarGroup id="tolbar">
                        <a4j:commandButton value="新增" action="#{assetEditBean.add}" render="editArea"/>
                        <a4j:commandButton value="保存"  action="#{assetEditBean.save}"
                                           render="editArea"
                                           onclick="this.disabled = 'true'"
                                           disabled="#{!assetEditBean.editStatus}"/>
                        <a4j:commandButton value="修改"  action="#{assetEditBean.update}"
                                           render="editArea"
                                           disabled="#{assetEditBean.addOrUpdate}"/>
                        <a4j:commandButton value="删除" action="#{assetEditBean.delete}"
                                           render="editArea"
                                           disabled="#{assetEditBean.addOrUpdate}"/>
                        <a4j:commandButton value="取消" action="#{assetEditBean.cancel}" render="editArea"/>                      
                    </rich:toolbarGroup>
                </rich:toolbar>
                <h:panelGrid columns="4" id="maininfo" style="width:670px;margin:5px 0px 5px 0px">
                    <h:outputText value="资产编号:"/>
                    <h:inputText  disabled="#{!assetEditBean.addOrUpdate || assetEditBean.editStatus}" id="assetCode"  value="#{assetEditBean.asset.assetCode}" />
                    <h:outputText value="资产名称:"/>
                    <h:inputText  disabled="#{!assetEditBean.editStatus}" id="assetName"  value="#{assetEditBean.asset.assetName}" size="50"/>
                    <h:outputText value="规格型号:"/>
                    <h:inputText  disabled="#{!assetEditBean.editStatus}" id="model"  value="#{assetEditBean.asset.model}" />
                    <h:outputText value="单价:"/>
                    <h:inputText  disabled="#{!assetEditBean.editStatus}" id="psw"  value="#{assetEditBean.asset.price}" />
                    <h:outputText value="品牌:"/>
                    <h:inputText  disabled="#{!assetEditBean.editStatus}" id="id"  value="#{assetEditBean.asset.brand}" />
                    <h:outputText value="厂商:"/>
                    <h:inputText  disabled="#{!assetEditBean.editStatus}" id="account"  value="#{assetEditBean.asset.manufacture}" />
                    <h:outputLabel value="购置日期:" />
                    <h:panelGroup id="purchDate">
                        <rich:calendar disabled="#{!assetEditBean.editStatus}" value="#{assetEditBean.asset.purchDate}"
                                       locale="zh_CN"
                                       popup="true"
                                       datePattern="yyyy-MM-dd"
                                       showApplyButton="false"  style="width:200px"/>
                    </h:panelGroup>
                    <h:outputLabel value="质保日期:" />
                    <h:panelGroup id="shelfLife">
                        <rich:calendar disabled="#{!assetEditBean.editStatus}" value="#{assetEditBean.asset.shelfLife}"
                                       locale="zh_CN"
                                       popup="true"
                                       datePattern="yyyy-MM-dd"
                                       showApplyButton="false"  style="width:200px"/>
                    </h:panelGroup>
                    <h:outputLabel value="使用状态:" />
                    <h:selectOneRadio id="useStatus" disabled="#{!assetEditBean.editStatus}" value="#{assetEditBean.asset.useStatus}">
                        <f:selectItem itemLabel="在用" itemValue="0"/>
                        <f:selectItem itemLabel="报废" itemValue="1"/>
                        <f:selectItem itemLabel="报损" itemValue="2"/>
                        <f:selectItem itemLabel="其他" itemValue="3"/>
                    </h:selectOneRadio>
                    <h:outputLabel value="部 门: " />
                    <h:selectOneMenu  value="#{assetEditBean.deptCode}" disabled="#{!assetEditBean.editStatus}">
                        <f:selectItem itemValue=" " itemLabel="-请选择-"/>
                        <f:selectItems value="#{assetEditBean.deptSelectli}"/>
                        <a4j:ajax event="change" listener="#{assetEditBean.deptChange}" render="usern,keeper"/>
                    </h:selectOneMenu>
                    <h:outputLabel value="使用人: " />
                    <h:panelGroup id="usern">
                        <h:selectOneMenu  id="ausername" disabled="#{!assetEditBean.editStatus}" value="#{assetEditBean.asset.person.cpsn_number}">
                            <f:selectItem itemValue=" " itemLabel="-请选择-"/>
                            <f:selectItems value="#{assetEditBean.personSelectli}" />
                        </h:selectOneMenu>
                    </h:panelGroup>
                    <h:outputLabel value="保管人： " />
                    <h:panelGroup id="keeper">
                        <h:selectOneMenu  id="keeperName"
                                          disabled="#{!assetEditBean.editStatus}"
                                          value="#{assetEditBean.asset.keeper.cpsn_number}">
                            <f:selectItem itemValue=" " itemLabel="-请选择-"/>
                            <f:selectItems value="#{assetEditBean.personSelectli}" />
                        </h:selectOneMenu>
                    </h:panelGroup>
                    <h:outputLabel value="保管地点：" />
                    <h:inputText  disabled="#{!assetEditBean.editStatus}" id="place"  value="#{assetEditBean.asset.place}" />
                    <h:outputText value="备注:"/>
                    <h:inputText  disabled="#{!assetEditBean.editStatus}" id="memo"  value="#{assetEditBean.asset.memo}" />
                </h:panelGrid>
                <h:panelGroup id="sasetEditGroup">
                    <rich:dataScroller for="assetInfo"/>
                    <div style="width:750px; min-height:260px; overflow: auto">
                        <rich:dataTable value="#{assetEditBean.assetmodel}" var="asset" id="assetInfo"
                                        style="max-height:260px; width:1230px;"
                                        rows="10">
                            <f:facet name="header">
                                <h:outputText value="资产信息" />
                            </f:facet>
                            <rich:column >
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="资产编号"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:commandLink action="#{assetEditBean.show}">
                                    <h:outputText  value="#{asset.assetCode}"/>
                                </h:commandLink>
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="资产名称"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:outputText value="#{asset.assetName}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText  value="规格型号"/>
                                </f:facet>
                                <h:outputText value="#{asset.model}"/>
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText  value="单价"/>
                                </f:facet>
                                <h:outputText value="#{asset.price}"/>
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText  value="品牌"/>
                                </f:facet>
                                <h:outputText value="#{asset.brand}"/>
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText  value="厂商"/>
                                </f:facet>
                                <h:outputText value="#{asset.manufacture}"/>
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText  value="购置日期"/>
                                </f:facet>
                                <h:outputText value="#{asset.purchDate}">
                                    <f:convertDateTime pattern="yyyy年MM月dd日" timeZone="GMT+8" locale="cn" />
                                </h:outputText>
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText  value="质保日期"/>
                                </f:facet>
                                <h:outputText value="#{asset.shelfLife}">
                                    <f:convertDateTime pattern="yyyy年MM月dd日" timeZone="GMT+8" locale="cn" />
                                </h:outputText>
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText  value="使用状况"/>
                                </f:facet>
                                <h:outputText value="在用"  rendered="#{asset.useStatus == '0'}"/>
                                <h:outputText value="报废"  rendered="#{asset.useStatus == '1'}" style="color:blue;"/>
                                <h:outputText value="报损"  rendered="#{asset.useStatus == '2'}" style="color:red;"/>
                                <h:outputText value="其他"  rendered="#{asset.useStatus == '3'}" style="color:ccddff;"/>
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText  value="代码"/>
                                </f:facet>
                                <h:outputText value="#{asset.person.cpsn_number}"/>
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText  value="使用人"/>
                                </f:facet>
                                <h:outputText value="#{asset.person.cpsn_name}"/>
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText  value="备注"/>
                                </f:facet>
                                <h:outputText value="#{asset.memo}"/>
                            </rich:column>
                        </rich:dataTable>
                    </div>
                </h:panelGroup>
            </h:panelGroup>
        </rich:panel>
    </h:form>
</ui:composition>